/*************************************************************************
  > File Name: VectorInsertAndPush.cpp
  > Author: 16hxliang3
  > Mail: 16hxliang3@stu.edu.cn
  > Created Time: Mon 16 May 2022 10:44:01 AM CST
 ************************************************************************/

#include <iostream>
#include <sys/types.h>
#include <vector>
int main()
{
  u_int32_t lim = 30000000;
  std::vector<std::string> a, b, c;
  a.reserve(lim- 10);
  b.resize(lim), c.resize(lim);
  std::string str = "Hello";
  auto start = clock();
  for(auto i = 0; i < lim; i++)
  {
    a.push_back(str);
  }
  auto finish = clock();
  std::cout << finish - start << std::endl;
  start = clock();
  for(auto i = 0; i < lim; i++)
  {
    if(i < (lim - 10))
      b[lim - i - 1] = str;
    else
      b.push_back(str);
  }
  finish = clock();
  std::cout << finish - start << std::endl;
  start = clock();
  for(auto i = 0; i < lim; i++)
  {
    c[i] = str;
  }
  finish = clock();
  std::cout << finish - start << std::endl;
}
